/*
 * @Author: 谢小康 2170673706@qq.com
 * @Date: 2024-01-02 14:34:40
 * @LastEditors: 谢小康 2170673706@qq.com
 * @LastEditTime: 2024-01-02 14:35:24
 * @FilePath: \My-bolg\server\model\PhotoAlbum.js
 * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
 */

const { DataTypes } = require('sequelize');
const sq = require('./db.js')
const { Sequelize } = require("sequelize")
const moment = require('moment')
const PhotoAlbum = sq.define(
  "photoalbum",
  {
    album_name: {
      type: DataTypes.STRING(26),
      require: true,
      comment: "相册名称",
    },
    album_cover: {
      type: DataTypes.STRING(555),
      require: true,
      comment: "相册封面",
    },
    description: {
      type: DataTypes.STRING(55),
      require: true,
      comment: "相册描述信息",
    },
    createdAt: {
      type: Sequelize.DATE,
      get() {
        return moment(this.getDataValue("createdAt")).format("YYYY-MM-DD HH:mm:ss")
      },
    },
    updatedAt: {
      type: Sequelize.DATE,
      get() {
        return moment(this.getDataValue("updatedAt")).format("YYYY-MM-DD HH:mm:ss")
      },
    },
  },
  {
    freezeTableName: true, // 强制表名不转复数
  }
)
/* PhotoAlbum.sync({ force: true }) */
module.exports = PhotoAlbum